/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cxt.DAO;

import com.cxt.Bean.BLBean;
import com.cxt.Bean.EdiBean;
import com.cxt.Bean.ManifiestoBean;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author jgutierrez
 */
public class EdiDAO {
    
    public static EdiBean leerEdi(String nombreArchivo) {
        
        EdiBean objEdiBean = new EdiBean();
        
        ArrayList<BLBean> lstBls = new ArrayList<>();
        ManifiestoBean objManifiesto = new ManifiestoBean();
        
        BLBean objBlBean = null;
        
        try (BufferedReader br = new BufferedReader(new FileReader(nombreArchivo))) {
            
            String sLine = "";
            
            while ( (sLine = br.readLine()) != null ) {
                
                if (sLine.length()>6 && sLine.substring(0, 4).equals("BGM+") ) {
                    
                    if (objBlBean != null) {
                        lstBls.add(objBlBean);
                    }
                    
                    objBlBean  = new BLBean();
                    //objBlBean.setNumbl(sLine);
                }
                
                else if (objBlBean != null) {
                    
                    // TODO: MAPEAR
                    
                    
                    
                    
                }
                
            }
            
            
        } catch (IOException ex) {
            Logger.getLogger(EdiDAO.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        
        objEdiBean.setLstBL(lstBls);
        
        
        return objEdiBean;
        
        
    }
}
